package action

import (
	"yunj/pkg/yunj/core/builder/builderaction"
)

// 删除
type Remove struct {
	Action
}

func NewRemove(title ...string) *Remove {
	a := &Remove{}

	builderaction.SetActionInstance(&a.Action.Action, a)
	a.SetActionCode("remove")
	if len(title) > 0 {
		a.SetTitle(title[0])
	}
	return a
}

// 设置标题
func (a *Remove) SetTitle(title string) *Remove {
	a.Title = title
	return a
}

// 设置额外的class或图标类名
func (a *Remove) SetClass(class string) *Remove {
	a.Class = class
	return a
}

// 设置权限
func (a *Remove) SetAuth(auth string) *Remove {
	a.Auth = auth
	return a
}

// 处理属性
func (a *Remove) HandleAttr() error {
	// 设置默认值
	if a.Title == "" {
		a.Title = "重命名"
	}
	if a.Class == "" {
		a.Class = "yunj-icon-rename"
	}
	return nil
}
